package com.djsearch.adapter;

import java.util.List;

import com.djsearch.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AlphaAnimation;
import android.view.animation.AnimationSet;
import android.view.animation.ScaleAnimation;
import android.widget.BaseExpandableListAdapter;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;


public class CityCheckExpListViewAdapter extends BaseExpandableListAdapter{
	


	private Context mContext;
	private List<String> groupArray;
	private List<List<String>> childArray;
	
	public CityCheckExpListViewAdapter(Context context,List<String> groupArray,
			List<List<String>> childArray){
		this.mContext = context;
		this.groupArray = groupArray;
		this.childArray = childArray;
	}
	
	@Override
	public int getGroupCount() {
		// TODO Auto-generated method stub
		 return groupArray.size();
	}

	@Override
	public int getChildrenCount(int groupPosition) {
		// TODO Auto-generated method stub
		return childArray.get(groupPosition).size(); 
	}

	@Override
	public Object getGroup(int groupPosition) {
		// TODO Auto-generated method stub
		return getGroup(groupPosition); 
	}

	@Override
	public Object getChild(int groupPosition, int childPosition) {
		// TODO Auto-generated method stub
		 return childArray.get(groupPosition).get(childPosition); 
	}

	@Override
	public long getGroupId(int groupPosition) {
		// TODO Auto-generated method stub
		return groupPosition ;  
	}

	@Override
	public long getChildId(int groupPosition, int childPosition) {
		// TODO Auto-generated method stub
		return childPosition;  
	}

	@Override
	public boolean hasStableIds() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public View getGroupView(int groupPosition, boolean isExpanded,
			View convertView, ViewGroup parent) {
		convertView = LayoutInflater.from(mContext).inflate(
				R.layout.city_check_group_list_item, null);// 用LayoutInflater装载布局。
        TextView groupTextView = (TextView)convertView.findViewById(R.id.provinceName);
        ImageView isExpandedImg = (ImageView)convertView.findViewById(R.id.isExpandedImg);
        groupTextView.setText(groupArray.get(groupPosition));
        if (isExpanded) {
        	//如果展开
        	isExpandedImg.setVisibility(View.VISIBLE);
        } else {
        	isExpandedImg.setVisibility(View.GONE);
        }
		return convertView;  
	}

	@Override
	public View getChildView(int groupPosition, int childPosition,
			boolean isLastChild, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		convertView = LayoutInflater.from(mContext).inflate(
				R.layout.city_check_list_itme, null);// 用LayoutInflater装载布局。
		TextView localText = (TextView)convertView.findViewById(R.id.cityName);
		
		String string =childArray.get(groupPosition).get(childPosition); 
		localText.setText(string);
		return convertView; 
	}

	@Override
	public boolean isChildSelectable(int groupPosition, int childPosition) {
		// TODO Auto-generated method stub
		return true; 
	}
	


}
